package aidturith.db.beans;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name = "artist_table")
public class Artist {

	@Id
	@GeneratedValue
	@Column(name = "artist_id")
	private int artist_id;

	@Column(name = "artist_name", nullable = false, updatable = true, unique = false)
	private String artist_name;

	@Column(name = "artist_web", nullable = true, updatable = true, unique = false)
	private String artist_web;

	@Column(name = "artist_gender", nullable = true, updatable = true, unique = false)
	private String artist_gender;

	@Column(name = "artist_country", nullable = true, updatable = true, unique = false)
	private String artist_country;

	@ManyToOne
	@JoinColumn(name = "id_circle")
	private Circle circle;

	@ManyToMany(mappedBy="composers")
	private Set<Music> music_compossed = new HashSet<Music>();

	@ManyToMany(mappedBy="composers")
	private Set<Subtitle> subtitle_compossed = new HashSet<Subtitle>();

	@ManyToMany(mappedBy="arrangers")
	private Set<Music> music_arranged = new HashSet<Music>();

	@ManyToMany(mappedBy="lyricists")
	private Set<Music> music_written = new HashSet<Music>();

	@ManyToMany(mappedBy="vocalists")
	private Set<Music> music_sung = new HashSet<Music>();

	@OneToMany(mappedBy="artist")
	@Cascade({CascadeType.ALL})
	private Set<Alias> aliases = new HashSet<Alias>();

	public Artist() {
		super();
	}

	public Artist(String artist_name) {
		super();
		this.artist_name = artist_name;
	}

	public Artist(String artist_name, String artist_gender) {
		super();
		this.artist_name = artist_name;
		this.artist_gender = artist_gender;
	}

	public Artist(String artist_name, String artist_gender, String artist_country) {
		super();
		this.artist_name = artist_name;
		this.artist_gender = artist_gender;
		this.artist_country = artist_country;
	}

	public String getArtist_name() { return artist_name; }
	public void setArtist_name(String artist_name) { this.artist_name = artist_name; }

	public String getArtist_web() { return artist_web; }
	public void setArtist_web(String artist_web) { this.artist_web = artist_web; }

	public String getArtist_gender() { return artist_gender; }
	public void setArtist_gender(String artist_gender) { this.artist_gender = artist_gender; }

	public String getArtist_country() { return artist_country; }
	public void setArtist_country(String artist_country) { this.artist_country = artist_country; }

	public Circle getCircle() { return circle; }
	public void setCircle(Circle circle) { this.circle = circle; }

	public Set<Music> getMusic_compossed() { return music_compossed; }
	public void setMusic_compossed(Set<Music> music_compossed) { this.music_compossed = music_compossed; }

	public Set<Subtitle> getSubtitle_compossed() { return subtitle_compossed; }
	public void setSubtitle_compossed(Set<Subtitle> subtitle_compossed) { this.subtitle_compossed = subtitle_compossed; }

	public Set<Music> getMusic_arranged() { return music_arranged; }
	public void setMusic_arranged(Set<Music> music_arranged) { this.music_arranged = music_arranged; }

	public Set<Music> getMusic_written() { return music_written; }
	public void setMusic_written(Set<Music> music_written) { this.music_written = music_written; }

	public Set<Music> getMusic_sung() { return music_sung; }
	public void setMusic_sung(Set<Music> music_sung) { this.music_sung = music_sung; }

	public Set<Alias> getAliases() { return aliases; }
	public void setAliases(Set<Alias> aliases) { this.aliases = aliases; }

	public void addAlias(Alias alias) {
		getAliases().add(alias);
		alias.setArtist(this);
	}

	@Override
	public String toString() { return artist_name; }

}
